package so.ifl.servcie.impl;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import so.ifl.commons.tools.Constant;
import so.ifl.dao.CompanyInfoDao;
import so.ifl.dao.SysDao;
import so.ifl.servcie.CompanyService;
import so.ifl.vo.CompanyVo;

/**
 *create by aaron.lu
 *create at 2011-12-19 上午10:28:10
 *<mailto: atyuan.lu@gmail.com>
 **/
@Service("companyService")
public class CompanyServcieImpl implements CompanyService{
	
	@Autowired
	private CompanyInfoDao companyInfoDao;
	
	@Autowired
	private SysDao sysDao;
	
	/**
	 * 
	 * create by aaron.lu
	 * create at 2011-12-19 上午10:32:03
	 * <mailto:atyuan.lu@gmail.com> 
	 * @param params 参数集
	 * @param offset 
	 * @param limit
	 * @return
	 *
	 */
	public List<CompanyVo> queryCompanyWithParamAndPagination(Map<String, Object> params, Integer offset, Integer limit){
		return companyInfoDao.queryCompanyWithParamAndPagination(params, new RowBounds(offset, limit));
	}

	/**
	 * 
	 * create by aaron.lu
	 * create at 2011-12-19 上午10:35:15
	 * <mailto: atyuan.lu@gmail.com>
	 * @param params
	 * @return
	 *
	 */
	public Integer countCompanyWithParam(Map<String, Object> params){
		return companyInfoDao.countCompanyWithParam(params);
	}
	
	/**
	 * 
	 * create by aaron.lu
	 * create at 2011-12-19 上午10:36:48
	 * <mailto: atyuan.lu@gmail.com>
	 * @param params
	 *
	 */
	public void insertCompany(Map<String, Object> params){
		params.put("company_bm_", sysDao.getSeq(Constant.JXT_COMPANY_SEQ));
		
		companyInfoDao.insertCompany(params);
	}
	
	/**
	 * 
	 * create by aaron.lu
	 * create at 2011-12-19 上午10:40:24
	 * <mailto: atyuan.lu@gmail.com>
	 * @param params
	 *
	 */
	public void updateCompany(Map<String, Object> params){
		companyInfoDao.updateCompany(params);
		
	}
	
	/**
	 * 
	 * create by aaron.lu
	 * create at 2011-12-19 上午10:41:26
	 * <mailto: atyuan.lu@gmail.com>
	 * @param companyId
	 *
	 */
	public void deleteCompany(Integer companyId){
		companyInfoDao.deleteCompany(companyId);
	}
}
